package com.jietong.rfid.uhf.service;

import java.util.Map;

import com.jietong.rfid.uhf.callback.CallBack;
import com.jietong.rfid.uhf.dao.impl.R2000Reader;
import com.jietong.rfid.util.AntStruct;
import com.jietong.rfid.util.FrequencyPoint;

public interface R2000ReaderService {
	/**
	 * SerialPort or Socket Connect
	 * @param portName
	 * @param baudRate
	 * @return Reader|null
	 */
	R2000Reader serialPortConnect(String portName, int baudRate, CallBack.R2000 callBack);
	
	/**
	 * 2.Disconnect
	 * @param reader
	 * @return true|false
	 */
	boolean disconnect(R2000Reader reader);
	
	/**
	 * 3.Get Version
	 * @param reader
	 * @return value|null
	 */
	String version(R2000Reader reader);
	
	/**
	 * 4.Inventory Read
	 * @param reader
	 * @return true|false
	 */
	@Deprecated
	boolean invOnce(R2000Reader reader);
	
	/**
	 * 5.Inventory Multiple
	 * @param reader
	 * @return true|false
	 */
	@Deprecated
	boolean beginInv(R2000Reader reader);
	/**
	 * 6.Stop Inventory
	 * @param reader
	 * @return true|false
	 */
	@Deprecated
	boolean stopInv(R2000Reader reader);
	
	/**
	 * 7.Get Antenna
	 * @param reader
	 * @return AntStruct|null
	 */
	AntStruct getAntenna(R2000Reader reader);
	
	/**
	 * 8.set Antenna
	 * @param reader
	 * @param ant Antenna No
	 * @return true|false
	 */
	boolean setAntenna(R2000Reader reader, AntStruct ant);
	
	/**
	 * 9.Designate Area Write data
	 * @param reader
	 * @param bank
	 * @param begin
	 * @param length
	 * @param data
	 * @param password
	 * @return true|false
	 */
	boolean writeTagData(R2000Reader reader, int bank, int begin, int length, String data, byte[] password);
	
	/**
	 * 10.Designate Area Read data
	 * @param reader
	 * @param bank Area
	 * @param begin start Address
	 * @param length
	 * @param password 
	 * @return value|null
	 */
	String readTagData(R2000Reader reader, byte bank, byte begin, byte length, byte[] password);
	
	/**
	 * 11.Lock Tag
	 * @param reader
	 * @param lockType Lock Tag Type
	 * @param lockBank Lock Area
	 * @param password
	 * @return ture|false
	 */
	boolean lockTag(R2000Reader reader, byte lockType, byte lockBank, byte[] password);
	
	/**
	 * 12.Get Buzzer Status(0.close|1.open)
	 * @param reader
	 * @return 
	 */
	int getBuzzer(R2000Reader reader);
	
	/**
	 * 13.Set Buzzer Status(0.close|1.open)
	 * @param reader
	 * @param state
	 * @return ture|false
	 */
	boolean setBuzzer(R2000Reader reader, byte state);
	
	/**
	 * 14.Set Work Pattern
	 * @param reader
	 * @param mode (01 master/slave mode��02 Timing mode��03 Trigger mode)
	 * @return true|false
	 */
	boolean setWorkMode(R2000Reader reader, int mode);
	
	/**
	 * 15.Get Work Pattern
	 * @param reader
	 * @return value(01 master/slave mode��02 Timing mode��03 Trigger mode) | -1
	 */
	int getWorkMode(R2000Reader reader);
	
	/**
	 * 16.Set Trigger Delay
	 * @param reader
	 * @param trigTime 
	 * @return true|false
	 */
	boolean setTriggerModeDelayTime(R2000Reader reader, byte trigTime);
	
	/**
	 * 17.get Trigger Delay
	 * @param reader
	 * @return value|-1
	 */
	int getTriggerModeDelayTime(R2000Reader reader);
	
	/**
	 * 18.Get Device No
	 * @param reader 
	 * @return value|null
	 */
	String getDeviceNo(R2000Reader reader);
	
	/**
	 * 19.Set Device No
	 * @param reader
	 * @param deviceNo
	 * @return true|false
	 */
	boolean setDeviceNo(R2000Reader reader, int deviceNo);
	
	/**
	 * 20.Kill Tag
	 * @param reader
	 * @param accessPwd  Visit Password
	 * @param killPwd	Kill Password
	 * @return 	true|false
	 */
	boolean killTag(R2000Reader reader, byte[] accessPwd, byte[] killPwd);
	
	/**
	 * 21.Set Output Mode
	 * @param reader
	 * @param outputMode(1 COM 2 NET 3 RS485 4 WIFI/USB->COM)
	 * @return true|false
	 */
	boolean setOutputMode(R2000Reader reader, byte outputMode);
	
	/**
	 * 22.Get Output Mode
	 * @param reader
	 * @return value|-1
	 */
	int getOutputMode(R2000Reader reader);

	/**
	 * 23.Get Adjacent discriminant
	 * @param reader
	 * @return
	 */
	Map<String,Byte> getAdjacentDiscriminant(R2000Reader reader);
	
	/**
	 * 24.set Adjacent Discriminant
	 * @param reader
	 * @param neighJudgeTime
	 * @return true|false
	 */
	boolean setAdjacentDiscriminant(R2000Reader reader, byte neighJudgeTime);
	
	/**
	 * 25.Get GPIO
	 * @param reader
	 * @param state
	 */
	Map<String, Boolean> getGPIO(R2000Reader reader);
	
	/**
	 * 26.Set GPIO
	 * @param reader
	 * @param time
	 * @return
	 */
	boolean setGPIO(R2000Reader reader, byte port, byte state);
	
	/**
	 * 27.Inventory Read_2018-11-30 new add
	 * @param reader 
	 * @return true|false
	 */
	boolean invOnceV2(R2000Reader reader);
	
	/**
	 * 28.Inventory Multiple_2018-11-30 new add
	 * @param reader
	 * @return true|false
	 */
	
	boolean beginInvV2(R2000Reader reader);
	/**
	 * 29.Stop Inventory_2018-11-30 new add
	 * @param reader
	 * @return true|false
	 */
	boolean stopInvV2(R2000Reader reader);
	
	/**
	 * 30.Get Read Mode Config_2018-11-30 new add
	 * @param reader
	 * @return (Integer session,Integer qValue,Integer tagFocus,Integer abValue)
	 */
	Map<String,Integer> getInvPatternConfig(R2000Reader reader);
	
	/**
	 * 31.Set Read Mode Config_2018-11-30 new add
	 * @param reader
	 * @param session
	 * @param qValue
	 * @param tagFocus
	 * @param abValue
	 * @return true|false
	 */
	boolean setInvPatternConfig(R2000Reader reader, byte session, byte qValue, byte tagFocus, byte abValue);
	
	/**
	 * 32.factory Data Reset 2018-11-30 new add
	 * @param reader
	 * @return true|false
	 */
	boolean factoryDataReset(R2000Reader reader);
	
	/**
	 * 33.Get Continue Read Tag Output Data format 2018-11-30 new add
	 * @param reader
	 * @return (Boolean antenna,Boolean rssi,Boolean deviceNo,Boolean accessDoorDirection)
	 */
	Map<String,Boolean> getInvOutPutData(R2000Reader reader);
	
	/**
	 * 34.Config Continue Read Tag Output Data format 2018-11-30 new add
	 * @param reader
	 * @param antenna 
	 * @param rssi
	 * @param deviceNo
	 * @param accessDoorDirection
	 * @return true|false
	 */
	boolean setInvOutPutData(R2000Reader reader, byte antenna, byte rssi, byte deviceNo, byte accessDoorDirection);
	
	/**
	 * 35.set Trigger Mode Alert Time
	 * @param reader
	 * @param time
	 * @return
	 */
	boolean setTriggerModeAlertTime(R2000Reader reader, byte time);
	
	/**
	 * 36.Get Antenna State 2018-11-30 new add
	 * @param reader
	 * @return 
	 */
	Map<String,Byte> getAntennaStatus(R2000Reader reader);
	
	/**
	 * 37.Read from the current frequency point defined 2018-11-30 new add
	 * @param reader
	 * @return 
	 */
	FrequencyPoint getFrequency(R2000Reader reader);
	
	/**
	 * 38.Sets the current frequency point under the custom 2018-11-30 new add
	 * 
	 * @param reader
	 * @param type
	 *            1.American-Standard(920.00-928.00)  |
	 *            2.Chinese standard1(920.50-924.50) |
	 *            3.Chinese standard2(840.50-844.50) |
	 *            4.European standard(866.00-867.50)  |
	 *            5.Customize frequency points(frequency hopping ) |
	 *            6.Customize frequency points(fixed frequency ) |
	 * @param frequencyData 
	 * 				type = 5   (byte[7]  Or 50bit(1byte = 8bit)) = boolean[50]|
	 * 				type = 6   (byte[3]  = double)|
	 * 				other type (null)
	 * @return true|false
	 */
	boolean setFrequency(R2000Reader reader, int type, double frequencyFixed, boolean[] frequencyHopping);
}
